package weiyao.xinxidasai.DTO;
import java.util.Base64;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@NoArgsConstructor
@Getter
@Setter
public class VerificationReport {
    private boolean valid;
    private boolean tampered;
    private int recoveredBytes;
    private int qualityScore;
    private String message;

    private byte[] decryptedData = new byte[0];
    private String recoveredFile;
    private String recoveredFileName;
    private String username;
    // 新增字段
    private String originalFile;      // Base64编码的原始文件
    private String originalFileName;  // 原始文件名

    private String embeddedToken;
    private int originalLength;

    public VerificationReport(boolean valid, boolean tampered, int recoveredBytes,
                              int qualityScore, String message, int originalLength) {
        this.valid = valid;
        this.tampered = tampered;
        this.recoveredBytes = recoveredBytes;
        this.qualityScore = qualityScore;
        this.message = message;
        this.originalLength = originalLength;
    }

    // 修改方法：接受byte[]参数
    public void setOriginalFile(byte[] data) {
        if (data == null) {
            this.originalFile = null;
        } else {
            this.originalFile = Base64.getEncoder().encodeToString(data);
        }
    }

    // 添加新字段的构造方法
    public VerificationReport(boolean valid, boolean tampered, int recoveredBytes,
                              int qualityScore, String message, int originalLength,
                              byte[] decryptedData) {
        this(valid, tampered, recoveredBytes, qualityScore, message, originalLength);
        this.decryptedData = decryptedData != null ? decryptedData : new byte[0];
    }

    @Override
    public String toString() {
        return String.format(
                "验证报告: %s | %s | 恢复字节: %d | 质量评分: %d/100",
                valid ? "有效" : "无效",
                message,
                recoveredBytes,
                qualityScore
        );
    }
}